<template>
    <view>
    <u-tabbar
      :height="110"
      v-model="current"
      :list="list"
      active-color="#02af74"
      :before-switch="beforeSwitch"
      @change="uTabbarM"
    ></u-tabbar>
    </view>
    </view>
</template>

<script lang='ts' >
import { Component, Prop, Vue, Watch, Emit } from "vue-property-decorator";

// import uTabbar from "@/uview-ui/components/u-tabbar/u-tabbar.vue";
import {AppModule} from '../../store/modules/app'

@Component({
  //   @Component  是一个装修器   不可以在下面写语句
  name: "bar",
})
export default class extends Vue {
  @Prop({
    type: String, // 父组件传递给子组件的数据类型
    required: false, // 是否必填
    default: " ", // 默认值， 如果传入的是 Object，则要 default: ()=>({}) 参数为函数
  })
  msg!: string;

  list = [
    {
      iconPath: "home",
      selectedIconPath: "home-fill",
      text: "首页",
      pagePath:'pages/home/home',
      count: 2,
      isDot: true,
      customIcon: false,
    },
    {
      iconPath: "photo",
      selectedIconPath: "photo-fill",
      text: "统计",
      pagePath:'pages/stati/index',
      customIcon: false,
    },
    {
      iconPath: "photo",
      selectedIconPath: "photo-fill",
      pagePath:'pages/equipment/index',
      text: "设备",
      customIcon: false,
    },
    // {
    // 	iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
    // 	selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
    // 	text: '发布',
    // 	midButton: true,
    // 	customIcon: false,
    // },
    {
      iconPath: "play-right",
      selectedIconPath: "play-right-fill",
      pagePath:'pages/cargo/index',
      text: "铺货",
      customIcon: false,
    },
    {
      iconPath: "account",
      selectedIconPath: "account-fill",
      pagePath:'pages/my/index',
      text: "个人",
      // count: 23,
      isDot: false,
      customIcon: false,
    },
  ];

  current = AppModule.selectBar ;

  created() {
     console.log(AppModule,'AppModule')
     console.log(this.current,'current')
  }

  mounted() {
    //  console.log('父组件传递的参数:',this.$parent)   //暂时不考虑
  }

  uTabbarM(){

     console.log('uTabbarM改变')

  }

  beforeSwitch(index:any) {
    console.log(index);

 



    if (index == 1) {

      uni.navigateTo({
        url: "../stati/index",
      });

      return true;

     }else if (index == 0) {
      uni.navigateTo({
        url: "../home/home",
      });
      return true;
     }
     else if (index == 2) {
      uni.navigateTo({
        url: "../equipment/index",
      });
      return true;
     }
     else if (index == 3) {
      uni.navigateTo({
        url: "../cargo/index",
      });
      return true;
     }
     else if (index == 4) {
     console.log('wan c444')
      uni.navigateTo({
        url: "../my/index",
      });
      return true;
     }

  }
  //    aaa(index:any){
  // }
}
</script>

<style  scoped>

</style>